﻿using eProcurement.DAL;
using eProcurement.helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace eProcurement.controls
{
    public partial class BidderItemControl : System.Web.UI.UserControl
    {
        protected void Page_Load( object sender, EventArgs e )
        {

        }

        public void Setup( Bid bid )
        {
            lblCompany.InnerText = bid.Supplier.CompanyName;
            lnkCompany.Attributes.Add( "href", "../members/SupplierProfile.aspx?sup=" + bid.SupplierId + "&bid=" + bid.Id + "&pid=" + bid.ProjectId );
            if ( bid.IsWinner )
            {
                lblBidWinner.InnerText = "BID AWARDED";
            }
            if ( bid.Supplier.Description.Length > 200 )
            {
                lblOverview.InnerText = bid.Supplier.Description.Substring( 0, 200 ) + "...";
            }
            else
            {
                lblOverview.InnerText = bid.Supplier.Description;
            }

            lblWebsite.InnerHtml = "<a href='" + SiteFormatter.FormatURL( bid.Supplier.Website ) + "'>" + bid.Supplier.Website + "</a>";
            if ( bid.Project.CloseDate > DateTime.Now )
            {
                lnkDownload.Attributes.Add( "href", "../members/Bidders.aspx?pid=" + bid.ProjectId );
                //lnkDownload.Attributes.Add( "class", "disabled" );
            }
            else
            {
                lnkDownload.Attributes.Add( "href", "../members/FileHandler.ashx?file=SD&" + "sup=" + bid.SupplierId + "&pid=" + bid.ProjectId );
            }
        }
    }
}